package com.winit.common.support.config;

import org.springframework.amqp.core.*;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Bean
    public MessageConverter jsonMessageConverter() {
        return new Jackson2JsonMessageConverter();
    }


    @Value("${cloudLink_send_exchange}")
    private String cloudLink_send_exchange;
    @Bean
    FanoutExchange exchange() {
        return new FanoutExchange(cloudLink_send_exchange);
    }

    @Bean
    public TopicExchange amqTopic() {
        return new TopicExchange("amq.topic");
    }

    @Bean
    Binding bindingExchange(TopicExchange amqTopic, FanoutExchange exchange) {
        return BindingBuilder.bind(amqTopic).to(exchange);
    }
}
